package by.semerikov.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import by.semerikov.constants.Results;
import by.semerikov.exceptions.DAOException;
import by.semerikov.form.DeleteTripForm;
import by.semerikov.model.Person;
import by.semerikov.model.Proposal;
import by.semerikov.service.ProposalService;
import by.semerikov.service.ServiceFactory;

public class DeleteTripAction extends SecuredAction {

	@Override
	public ActionForward executedInternal(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response, Person user) throws DAOException {
		DeleteTripForm _form = (DeleteTripForm) form;
		if (_form.getId() != null) {
			Proposal newProposal = new Proposal(_form.getId(), null, null,
					null, null, null, null, null);

			ProposalService proposalService = ServiceFactory.getInstance()
					.getProposalService();
			proposalService.deleteProposal(newProposal);
		}
		return mapping.findForward(Results.SUCCESS);
	}
}
